// pages/home/home.js
//引入代码
var call = require('../../utils/request')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    //幻灯片素材
    swiperImg: [
      { src: 'http://api.jisuapi.com/recipe/upload/20160719/120910_28888.jpg'},
      { src: 'http://api.jisuapi.com/recipe/upload/20160719/121034_85182.jpg'},
      { src: 'http://api.jisuapi.com/recipe/upload/20160719/162652_48365.jpg'}
    ],
    list:[],
    name:'',//菜名,
    nodes: []


  },
  jump:function(e){
    let that = this;
    // console.log(e,'e')
    let date={}
    date.name = e.currentTarget.dataset.name
    date.id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../details/details?date=' + JSON.stringify(date)
    })
  },
  more_btn:function(){
    wx.switchTab({
      url: '../classification/classification',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    //参数
    let url='/recipe/search'
    let date={
      keyword:'白菜',
      num:20,
      appkey:'928cbbc1f0636217'
    }
    call.request(url,date).then(res => {
      // console.log('res', res)
      // console.log('dddd', res.data.result.list)
      that.setData({list:res.data.result.list})
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})